package com.yycwxt.modules.admin.sale;


import java.util.Map;

public class SaleSelectProvider {

    public String getsalesql(Integer zq){
        StringBuilder sql = new StringBuilder();
        String first = """
                 ,sum(case when subject_code = '9001-01-002' then cost end) '实际销售金额'
                    ,count(order_number) '销售订单'
                    ,sum(case when subject_code = '1004-01-010' then cost end) 'SD佣金'
                    ,sum(case when subject_code = '1004-01-001' then cost end) '直通车'
                    ,sum(case when subject_code = '1004-01-002' then cost end) '超级推荐'
                    ,sum(case when subject_code = '1004-01-004' or subject_code = '1004-01-005' or subject_code = '1004-01-006' then cost end) '钻石展位'
                    ,sum(case when subject_code = '1004-01-003' then cost end) '淘宝客'
                    ,sum(case when subject_code = '1004-01-007' then cost end) '京东'
                    ,sum(case when subject_code = '1004-01-008' or subject_code = '1004-01-009' then cost end) '拼多多'
                """;

        sql.append("select glb_shop.`name` '店铺'");
        sql.append(first);
        sql.append(" from yycwxt_test.core_flows join yycwxt_test.glb_shop on yycwxt_test.glb_shop.code = yycwxt_test.core_flows.shop_code");
        String tem = """
                 where subject_code like '1004-%' and account_date = '%s'
                """;
        sql.append(String.format(tem,zq));
        sql.append(" group by glb_shop.`name`");
        return sql.toString();

    }
}
